package com.pw.study.flink.transfrom

import com.pw.study.flink.entities.UserBean
import org.apache.flink.api.common.functions.RichMapFunction
import org.apache.flink.configuration.Configuration

import scala.collection.mutable.ArrayBuffer

class MyRichMap extends RichMapFunction[UserBean,ArrayBuffer[UserBean]]{

  override def open(parameters: Configuration): Unit = {
    println("open.......")
  }
  override def map(in: UserBean): ArrayBuffer[UserBean] = {
    val beans: ArrayBuffer[UserBean] = ArrayBuffer[UserBean]()

    for(i<- 1 to 5 ){
      val bean: UserBean = UserBean("Rich_" + in.id + "i_" + i, in.ts, in.vc)
      beans.+=(bean)
    }
    println("size: "+beans.length)
    println("beans: "+beans.mkString)
    beans
  }

  override def close(): Unit = {
    println("close............")

  }
}
